package router

import (
	"github.com/gin-gonic/gin"
	"go_my_framework/app/controller/admin"
	"go_my_framework/app/middleware"
)

func AdminRouter(r *gin.Engine) {
	ar := r.Group("admin")
	// 权限校验中间件
	ar.Use(middleware.AuthMiddleware)
	// 注册路由
	ar.GET("login/login", admin.Login)
	ar.POST("login/login", admin.Login)
	ar.GET("login/logout", admin.Logout)
	ar.GET("login/notFound", admin.NotFound)
	ar.GET("captcha", admin.BuildCaptcha)
	ar.GET("captcha/:captchaId", admin.GetCaptchaImg)
	ar.POST("captcha/verify", admin.VerifyCaptcha)

	// 首页
	ar.GET("index", admin.Index)
	ar.POST("index", admin.Index)
	ar.GET("index/index", admin.Index)

	// 管理员
	ar.GET("admin/index", admin.AdminIndex)
	ar.POST("admin/index", admin.AdminIndex)
	ar.GET("admin/add", admin.AdminAdd)
	ar.POST("admin/add", admin.AdminAdd)
	ar.GET("admin/edit", admin.AdminEdit)
	ar.POST("admin/edit", admin.AdminEdit)
	ar.POST("admin/del", admin.AdminDel)

	// 角色
	ar.GET("role/index", admin.RoleIndex)
	ar.POST("role/index", admin.RoleIndex)
	ar.GET("role/add", admin.RoleAdd)
	ar.POST("role/add", admin.RoleAdd)
	ar.GET("role/edit", admin.RoleEdit)
	ar.POST("role/edit", admin.RoleEdit)
	ar.POST("role/del", admin.RoleDel)
	ar.GET("role/privilege", admin.Privilege)
	ar.POST("role/privilege", admin.Privilege)

	// 权限
	ar.GET("purview/index", admin.PurviewIndex)
	ar.GET("purview/add", admin.PurviewAdd)
	ar.POST("purview/add", admin.PurviewAdd)
	ar.GET("purview/edit", admin.PurviewEdit)
	ar.POST("purview/edit", admin.PurviewEdit)
	ar.POST("purview/del", admin.PurviewDel)

	// 文章
	ar.GET("article/index", admin.ArticleIndex)
	ar.POST("article/index", admin.ArticleIndex)
	ar.GET("article/add", admin.ArticleAdd)
	ar.POST("article/add", admin.ArticleAdd)
	ar.GET("article/edit", admin.ArticleEdit)
	ar.POST("article/edit", admin.ArticleEdit)
	ar.POST("article/del", admin.ArticleDel)

	// 分类
	ar.GET("category/index", admin.CategoryIndex)
	ar.GET("category/add", admin.CategoryAdd)
	ar.POST("category/add", admin.CategoryAdd)
	ar.GET("category/edit", admin.CategoryEdit)
	ar.POST("category/edit", admin.CategoryEdit)
	ar.POST("category/del", admin.CategoryDel)
}
